home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / prg_casm / snpd9611.zip / PTRTUTOR.TXT < prev    next >
Text File  |  1996-11-24  |  5KB  |  200 lines

  1. .I 0 3
  2. +++Date last modified: 02-Jun-1996
  3.  
  4. PTRTUT03.TXT   6/1/96
  5. .D 1 1
  6. .I 4 1
  7.                       Version 0.3
  8. .D 5 1
  9. .I 85 1
  10. goal is via feedback from those who find this material useful.
  11. .D 86 1
  12. .I 93 3
  13. P.O. Box 324                      1-415-365-8452
  14. Redwood City, CA 94064
  15. Dec. 1995
  16. .D 94 3
  17. .I 180 8
  18.     However, the above definition of "lvalue" is somewhat
  19. modified for C to be..
  20.  
  21.      An _object_ is a region of storage; an _lvalue_ is an
  22.      expression referring to an object.
  23.  
  24. As we become more familiar with pointers we will go into more
  25. detail on this.
  26. .D 181 9
  27. .I 258 1
  28.     What the '&' operator does is retrieve the address
  29. .D 259 1
  30. .I 286 6
  31. ------------ Program 1.1 ---------------------------------
  32.  
  33. /* Program 1.1 from PTRTUT02.TXT   12/14/95 */
  34.  
  35. #include <stdio.h>
  36.  
  37. .D 287 3
  38. .I 406 4
  39. -----------  Program 2.1  -----------------------------------
  40. /* Program 2.1 from PTRTUT02.TXT   12/14/95 */
  41.  
  42.  
  43. .D 407 1
  44. .I 465 3
  45.     Earlier when discussing the term "lvalue" I stated that
  46.  
  47.     "An _object_ is a region of storage; an _lvalue_ is an
  48. .D 466 4
  49. .I 587 3
  50. /* Program 3.1 from PTRTUT02.TXT   12/14/95 */
  51.  
  52.  
  53. .I 680 1
  54.         char *p = destination;
  55. .D 681 1
  56. .I 686 1
  57.         return destination;
  58. .D 687 1
  59. .I 724 1
  60. incrementing the pointer value.  This has to
  61. .D 725 1
  62. .I 909 5
  63. /* Program 5.1 from PTRTUT02.TXT   12/14/95 */
  64.  
  65. #include <stdio.h>
  66. #include <string.h>
  67.  
  68. .D 910 3
  69. .I 919 1
  70. struct tag my_struct;       /* declare the structure my_struct */
  71. .D 920 1
  72. .I 999 2
  73. ------------ program 5.2 ---------------------
  74. /* Program 5.2 from PTRTUT02.TXT   12/14/95 */
  75. .D 1000 1
  76. .I 1202 2
  77. /* Program 6.1 from PTRTUT02.TXT   12/14/95 */
  78.   
  79. .I 1425 1
  80. arr2d, assigning the address of the two dimensional array arr2d to
  81. .D 1426 1
  82. .I 1488 1
  83.     for(k = 0; k < 10; k++)
  84. .D 1489 1
  85. .I 1542 6
  86. --------------- Program 9.1 --------------------------------
  87. /* Program 9.1 from PTRTUT02.TXT   12/14/95 */
  88.  
  89. #include <stdio.h>
  90. #include <alloc.h>
  91.  
  92. .D 1543 2
  93. .I 1553 1
  94.   rptr = malloc(nrows * COLS * sizeof(int));
  95. .D 1554 1
  96. .I 1559 3
  97.    return 0;
  98. }
  99. ------------- End of Prog. 9.1 --------------------------------
  100. .D 1560 2
  101. .I 1608 4
  102. -------------- Program 9.2 ------------------------------------
  103. /* Program 9.2 from PTRTUT02.TXT   12/14/95 */
  104.  
  105. #include <stdio.h>
  106. .D 1609 2
  107. .I 1616 1
  108.   int row;
  109. .D 1617 1
  110. .I 1640 1
  111. --------------- End 9.2 ------------------------------------
  112. .D 1641 2
  113. .I 1679 4
  114. ----------------- Program 9.3 -----------------------------------
  115. /* Program 9.3 from PTRTUT02.TXT   12/14/95 */
  116.  
  117. #include <stdio.h>
  118. .D 1680 2
  119. .I 1694 1
  120.   aptr = malloc(nrows * ncols * sizeof(int));
  121. .D 1695 1
  122. .I 1747 1
  123. ------------- End Program 9.3 -----------------
  124. .D 1748 1
  125. .I 1774 4
  126. ------------------- Program 9.4 -------------------------------------
  127. /* Program 9.4 from PTRTUT02.TXT   12/14/95 */
  128.  
  129. #include <stdio.h>
  130. .D 1775 2
  131. .I 1788 1
  132.   int y, z;
  133. .D 1789 1
  134. .I 1838 1
  135. ------------------- End of Prog. 9.4 ----------------------------
  136. .D 1839 1
  137. .I 1901 1
  138. /* Program bubble_1.c from PTRTUT02.TXT   12/14/95 */
  139. .I 1962 1
  140. to the actual algorithm.  This results in bubble_2.c:
  141. .D 1963 1
  142. .I 1965 2
  143. /* Program bubble_2.c from PTRTUT02.TXT   12/14/95 */
  144.  
  145. .I 2018 6
  146. /* Program bubble_3.c from PTRTUT02.TXT   12/14/95 */
  147.  
  148. #include <stdio.h>
  149.  
  150. int arr[10] = { 3,6,1,2,3,8,4,1,7,2};
  151.  
  152. .D 2019 4
  153. .I 2072 6
  154. /* Program bubble_4.c from PTRTUT02.TXT   12/14/95 */
  155.  
  156. #include <stdio.h>
  157.  
  158. int arr[10] = { 3,6,1,2,3,8,4,1,7,2};
  159.  
  160. .D 2073 4
  161. .I 2133 1
  162. Currently, in bubble_4.c, knowledge within bubble() as to the
  163. .D 2134 1
  164. .I 2148 5
  165. /* Program bubble_5.c from PTRTUT02.TXT   12/14/95 */
  166.  
  167. #include <stdio.h>
  168. #include <string.h>
  169.  
  170. .D 2149 3
  171. .I 2229 5
  172. /* Program bubble_6.c from PTRTUT02.TXT   12/14/95 */
  173.  
  174. #include <stdio.h>
  175. #include <string.h>
  176.  
  177. .D 2230 3
  178. .I 2327 5
  179. /* Program bubble_7.c from PTRTUT02.TXT   12/14/95 */
  180.  
  181. #include <stdio.h>
  182. #include <string.h>
  183.  
  184. .D 2328 3
  185. .I 2422 13
  186. Bob Stout's collection of C code SNIPPETS.  The content in this
  187. version is the same as that in PTRTUTOT.ZIP included in
  188. SNIP9510.ZIP with some minor typo corrections.
  189.  
  190. I am always ready to accept constructive criticism on this
  191. material, or review requests for the addition of other relevant
  192. material.  Therefore, if you have questions, comments,
  193. criticisms, etc. concerning that which has been presented, I
  194. would greatly appreciate your contacting me using one of the mail
  195. addresses cited in the Introduction.
  196.  
  197.  
  198.  
  199. .D 2423 8
  200.